import { requestClient } from '#/api/request';

export function AddObj(obj: any) {
  return requestClient.request('/iam/tenant/setting', {
    method: 'post',
    data: obj,
  });
}

export function DelObj(id: any) {
  return requestClient.request(`/iam/tenant/setting/${id}`, {
    method: 'delete',
    data: { id },
  });
}

export function UpdateObj(obj: any) {
  return requestClient.request(`/iam/tenant/setting/${obj.id}`, {
    method: 'put',
    data: obj,
  });
}

export function GetPage(query: any) {
  return requestClient.post(`/iam/tenant/setting/page`, {
    page: { current: query.current, size: query.size },
    model: {
      provinceId: query?.area?.[0],
      cityId: query?.area?.[1],
      districtId: query?.area?.[2],
    },
  });
}

export function DatabaseSet(form: any) {
  return requestClient.get('/iam/tenant/database/active', {
    params: form,
  });
}

export function getTenantSetting(tenantId: any) {
  return requestClient.get(`/iam/tenant/setting/${tenantId}/setting`);
}

export function setTenantSetting(form: any) {
  return requestClient.put(
    `/iam/tenant/setting/${form.tenantId}/setting`,
      form,
    {
      fetchOptions: { mode: 'full' },
    },
  );
}
